package com.ruoyi.web.controller.control;

import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.control.domain.Belt;
import com.ruoyi.control.service.IBeltService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.util.List;

/**
 * 皮带实时Controller
 * 
 * @author ruoyi
 * @date 2024-11-09
 */
@RestController
@RequestMapping("/control/belt")
public class BeltController extends BaseController
{
    @Autowired
    private IBeltService beltService;

    /**
     * 查询皮带实时列表
     */
    @PreAuthorize("@ss.hasPermi('control:belt:list')")
    @GetMapping("/list")
    public TableDataInfo list(Belt belt)
    {
        startPage();
        List<Belt> list = beltService.selectBeltList(belt);
        return getDataTable(list);
    }

    /**
     * 查询皮带实时列表
     */
    @PreAuthorize("@ss.hasPermi('control:belt:list')")
    @GetMapping("/getList")
    public List<Belt> getList()
    {
        List<Belt> list = beltService.getList();
        return list;
    }

    /**
     * 导出皮带实时列表
     */
    @PreAuthorize("@ss.hasPermi('control:belt:export')")
    @Log(title = "皮带实时", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, Belt belt)
    {
        List<Belt> list = beltService.selectBeltList(belt);
        ExcelUtil<Belt> util = new ExcelUtil<Belt>(Belt.class);
        util.exportExcel(response, list, "皮带实时数据");
    }

    /**
     * 获取皮带实时详细信息
     */
    @PreAuthorize("@ss.hasPermi('control:belt:query')")
    @GetMapping(value = "/{tagName}")
    public AjaxResult getInfo(@PathVariable("tagName") String tagName)
    {
        return success(beltService.selectBeltByTagName(tagName));
    }

    /**
     * 新增皮带实时
     */
    @PreAuthorize("@ss.hasPermi('control:belt:add')")
    @Log(title = "皮带实时", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody Belt belt)
    {
        return toAjax(beltService.insertBelt(belt));
    }

    /**
     * 修改皮带实时
     */
    @PreAuthorize("@ss.hasPermi('control:belt:edit')")
    @Log(title = "皮带实时", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody Belt belt)
    {
        return toAjax(beltService.updateBelt(belt));
    }

    /**
     * 删除皮带实时
     */
    @PreAuthorize("@ss.hasPermi('control:belt:remove')")
    @Log(title = "皮带实时", businessType = BusinessType.DELETE)
	@DeleteMapping("/{tagNames}")
    public AjaxResult remove(@PathVariable String[] tagNames)
    {
        return toAjax(beltService.deleteBeltByTagNames(tagNames));
    }

    /**
     * 大屏  皮带运输   开停状态  速度、电压、电流
     */
    @GetMapping("/getPdValueList")
    public List<Belt> getPdValueList()
    {
        List<Belt> list = beltService.getPdValueList();
        return list;
    }

    /**
     * 大营接口
     */

    /**
     * 皮带   电流、前轴温度、后轴温度、绕组温度     变频器：电压、给定频率、运行频率
     */
    @GetMapping("/getDyPdSsValueList")
    public List<Belt> getDyPdSsValueList()
    {
        List<Belt> list = beltService.getDyPdSsValueList();
        return list;
    }

    /**
     * 皮带速度
     */
    @GetMapping("/getDyPdSdValueList")
    public List<Belt> getDyPdSdValueList()
    {
        List<Belt> list = beltService.getDyPdSdValueList();
        return list;
    }


    /**
     * 大营大屏  皮带运输   开停状态  速度、电流
     */
    @GetMapping("/getDyDpPdValueList")
    public List<Belt> getDyDpPdValueList()
    {
        List<Belt> list = beltService.getDyDpPdValueList();
        return list;
    }



    /**
     * 皮带运行模式 状态
     */
    @GetMapping("/getDyPdStatusList")
    public List<Belt> getDyPdStatusList()
    {
        List<Belt> list = beltService.getDyPdStatusList();
        return list;
    }

}
